package com.mall.utils;

public class ThreadLocalUtil {
    private static ThreadLocal<Long> tl = new ThreadLocal<>();

    //本地线程存储当前用户id
    public static void setId(Long id) {
        tl.set(id);
    }

    //本地线程获取当前用户id
    public static Long getId() {
        return tl.get();
    }

    //清楚本地线程变量副本
    public static void remove() {
        tl.remove();
    }
}
